<?php
/**
 * Created by PhpStorm.
 * User: 张红雨
 * Date: 2018/11/11
 * Time: 9:31
 */
namespace Api\Controller;
class TestController extends BaseController {
    public function testJpush() {
        //        $jpushSend = JpushAlertSend('学生【张红雨】', '图片', '', 'homework_new', 'all', 10 * 86400);//保留十天
        //        succeed($jpushSend);
        $res = shell_exec("C:/ffmpeg/bin/ffmpeg -i  C:/phpStudy/PHPTutorial/WWW/shuidiFuDao/Public/upload/record/reply/20181114/5bec43aeeb926.amr  C:/phpStudy/PHPTutorial/WWW/shuidiFuDao/Public/upload/record/reply/20181114/5bec43aeeb926.mp3");
        succeed($res);
    }

    //    public function updateUserBalance() {
    //        //查询所有的用户分享
    //        $rank_share_list = M('ranking')->field('id,uid_leader')->select();
    //        foreach ($rank_share_list as $key => $value) {
    //            $count = M('balance_add_log')->where(array(
    //                'rank_id' => $value['id']
    //            ))->count();
    //            if ($count > 0) {
    //                continue;
    //            }
    //            //充值，用事务
    //            M()->startTrans();
    //            $balance = 0.01;
    //            $current_time = time();
    //            $res = M('user')->where(array(
    //                'uid' => $value['uid_leader']
    //            ))->save(array(
    //                'balance'     => array('exp', 'balance+' . $balance),
    //                'update_time' => $current_time
    //            ));
    //            //记录到日志中
    //            $log_add_res = M('balance_add_log')->add(array(
    //                'uid'         => $value['uid_leader'],
    //                'money'       => $balance,
    //                'type'        => 2,
    //                'rank_id'     => $value['id'],
    //                'create_time' => $current_time,
    //                'update_time' => $current_time
    //            ));
    //            if ($res && $log_add_res) {
    //                M()->commit();
    //            } else {
    //                M()->rollback();
    //            }
    //        }
    //        succeed(null);
    //    }
    public function getUserInfo() {
        $res = M()->query("select count(q.qid) as questionCount,u.balance from t_user  u
              LEFT JOIN  t_question q
          ON q.uid='rcw742vqge6n0i1' AND u.uid=q.uid");
//        $res[0]['balance'] = $res[0]['balance'] == null ? '0.00' : $res[0]['balance'];
        succeed($res);
    }
}